package com.oauth.linkedin.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DeckPanel;
import com.oauth.components.client.rpc.OAuthAsnyCallBack;
import com.oauth.linkedin.client.beans.LinkedinModel;
import com.oauth.linkedin.client.rpc.LinkedinRemoteServiceAsync;

public class MainPanel extends Composite {

	private static MainPanelUiBinder uiBinder = GWT.create(MainPanelUiBinder.class);

	interface MainPanelUiBinder extends UiBinder<DeckPanel, MainPanel> {
	}

	/**
	 * Create a remote service proxy to talk to the server-side Greeting
	 * service.
	 */

	@UiField
	DeckPanel deckPanel;

	@UiField
	HomePanel homePanel;

	public MainPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public void initMainPanel() {
		deckPanel.showWidget(0);
		LinkedinRemoteServiceAsync.INSTANCE.getLinkedInData(new OAuthAsnyCallBack<LinkedinModel>() {

			public void onSuccess(LinkedinModel result) {
				homePanel.setData(result);
				deckPanel.showWidget(1);
			}

		});
	}

}